package com.suptrack.web.servlet;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.suptrack.entity.Car;
import com.suptrack.entity.User;
import com.suptrack.service.CarService;

/**
 * Servlet implementation class editCarServlet
 */
@WebServlet("/RegisteredContent/editCar")
public class editCarServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	@EJB
	CarService carservice;
	
   
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		long id = Long.parseLong(request.getParameter("id"));
		String _name = request.getParameter("c_name");
		String _brand = request.getParameter("c_brand");
		String _ney = request.getParameter("c_ney");
		
		Car _car = carservice.getCarInfoService(id);
		_car.setBrand(_brand);
		_car.setFirstEntryYear(_ney);
		_car.setName(_name);
		carservice.editCarService(_car);
		response.sendRedirect(request.getServletContext().getContextPath()+"/RegisteredContent/ManageCar");
			
	}

}
